﻿using Searching.Core;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CodeToolBox.Form
{
    public partial class ToolPasswordForm : UIForm
    {
        public ToolPasswordForm()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uiButton1_Click(object sender, EventArgs e)
        {
            try
            {
                textBox2.Text = "";
                string tet1 = textBox1.Text;
                if (string.IsNullOrWhiteSpace(tet1.Trim())) throw new Exception("明文不能为空！");
                CryptoUtil CryptManager = new CryptoUtil(enumCrypType.DES);
                string resultstr = CryptManager.Encrypting(tet1, "SECH");
                textBox2.Text = resultstr;
            }
            catch (Exception ex)
            {

                ShowErrorTip(ex.Message, 2000, true);
            }
        }
        /// <summary>
        /// 解密
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uiButton2_Click(object sender, EventArgs e)
        {
            try
            {
                textBox1.Text = "";
                string tet2 = textBox2.Text;
                if (string.IsNullOrWhiteSpace(tet2.Trim())) throw new Exception("密文不能为空！");
                CryptoUtil CryptManager = new CryptoUtil(enumCrypType.DES);
                string resultstr = CryptManager.Decrypting(tet2, "SECH");
                textBox1.Text = resultstr;
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
    }
}
